import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
const router = new Router({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'Home',
      component: () => import(/* webpackChunkName: "about" */ './views/home/Home.vue'),
      meta: {
        title: '附近电站'
      }
    },
    {
      path: '/Stations',
      name: 'Stations',
      component: () => import(/* webpackChunkName: "about" */ './views/stations/index.vue'),
      meta: {
        title: '充电站'
      }

    },
    {
      path: '/AddressFeek',
      name: 'FeedBack',
      component: () => import(/* webpackChunkName: "about" */ './views/addressFeek/index.vue'),
      meta: {
        title: '设备报修'
      }
    },
    {
      path: '/FeedBack',
      name: 'FeedBack',
      component: () => import(/* webpackChunkName: "about" */ './views/feedBack/index.vue'),
      meta: {
        title: '地址反馈'
      }
    },
    {
      path: '/Pay',
      name: 'pay',
      component: () => import(/* webpackChunkName: "about" */ './views/pay/index.vue'),
      meta: {
        title: '付款'
      }
    },
    {
      path: '/Material',
      name: 'Material',
      component: () => import(/* webpackChunkName: "about" */ './views/material/index.vue'),
      meta: {
        title: '个人信息'
      }
    },
    {
      path: '/Collections',
      name: 'Collections',
      component: () => import(/* webpackChunkName: "about" */ './views/collections/index.vue'),
      meta: {
        title: '我的收藏'
      }
    },
    {
      path: '/Help',
      name: 'help',
      component: () => import(/* webpackChunkName: "about" */ './views/help/index.vue'),
      meta: {
        title: '帮助'
      }
    },
    {
      path: '/Suggest',
      name: 'Suggest',
      component: () => import(/* webpackChunkName: "about" */ './views/suggest/index.vue'),
      meta: {
        title: '建议'
      }
    },
    {
      path: '/About',
      name: 'About',
      component: () => import(/* webpackChunkName: "about" */ './views/about/index.vue'),
      meta: {
        title: '关于我们'
      }
    },
    {
      path: '/Order',
      name: 'Order',
      component: () => import(/* webpackChunkName: "about" */ './views/order/index.vue'),
      meta: {
        title: '订单'
      }
    },
    {
      path: '/Add',
      name: 'Add',
      component: () => import(/* webpackChunkName: "about" */ './views/add/index.vue'),
      meta: {
        title: '加盟'
      }
    },
    {
      path: '/Center',
      name: 'Center',
      component: () => import(/* webpackChunkName: "about" */ './views/center/index.vue'),
      meta: {
        title: '个人中心'
      }
    },
    {
      path: '/Message',
      name: 'Message',
      component: () => import(/* webpackChunkName: "about" */ './views/message/index.vue'),
      meta: {
        title: '消息通知'
      }
    },
    {
      path: '/MSGmanager',
      name: 'MSGmanager',
      component: () => import(/* webpackChunkName: "about" */ './views/message/MSGmanager/index.vue'),
      meta: {
        title: '消息通知'
      }
    },
    {
      path: '/Pack',
      name: 'Pack',
      component: () => import(/* webpackChunkName: "about" */ './views/pack/index.vue'),
      meta: {
        title: '我的钱包'
      }
    },
    {
      path: '/water',
      name: 'Water',
      component: () => import(/* webpackChunkName: "about" */ './views/water/index.vue'),
      meta: {
        title: '充值明细'
      }
    },
    {
      path: '/login',
      name: 'login',
      component: () => import(/* webpackChunkName: "about" */ './views/login/index.vue'),
      meta: {
        title: '登录'
      }
    },
    {
      path: '/sussess',
      name: 'sussess',
      component: () => import(/* webpackChunkName: "about" */ './views/sussess/index.vue'),
      meta: {
        title: '充电'
      }
    },
  ]
})

// 全局路由守卫
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
});

export default router;
